<?php

function make_date($datestamp) {

	$datestamp_yy = substr($datestamp,0,4);
	$datestamp_mm = substr($datestamp,5,2);
	$datestamp_dd = substr($datestamp,8,2);
	
	return mktime(0,0,0,$datestamp_dd,$datestamp_yy,$datestamp_mm);

}

function make_datepicker() {
	
	$date_now = time();
	$date_now_yy = date("Y",$date_now);
	$date_now_mm = date("m",$date_now);
	$date_now_dd = date("d",$date_now);
	
	$date_index = 0;
	
	$output = "";
	
	for($date_index=0;$date_index<7;$date_index++) {
		$date_value = mktime(0,0,0,$date_now_mm,$date_now_dd-6+$date_index,$date_now_yy);
		if($date_index==6) { $selected="selected"; } else { $selected=""; }
		$output .= "<option $selected value='".date("Y-m-d",$date_value)."'>".date("D d/m/Y",$date_value)."</option>";
	}
	
	return $output;
	
}

function build_flat_data() {
	
	global $db_host, $db_username, $db_password, $db_database;

	mysql_connect($db_host,$db_username,$db_password);
	mysql_select_db($db_database) or die("Unable to select database");
	
	$db_query = "DROP TABLE IF EXISTS report;";
	$db_result = mysql_query($db_query);

	$db_query = "CREATE TABLE report;";
	$db_result = mysql_query($db_query);	
	
			
}

?>
